package edu.sctu.jarime.may.subway.util;

import edu.sctu.jarime.may.subway.appbean.PeopleAppbean;
import edu.sctu.jarime.may.subway.appbean.SubwayAppbean;
import edu.sctu.jarime.may.subway.data.SetPeopleData;
import edu.sctu.jarime.may.subway.data.SetSubwayDate;

/**
 * Created by user19 on 2015/6/2.
 */
public class PeopleDeth {


    public void getIntoSubwayStation(PeopleAppbean people,SubwayAppbean subwayAppbean) {

        int a;
        for (a = 0; a <new SetPeopleData().setpeopledata().size(); a++) {

            people = new SetPeopleData().setpeopledata().get(a);
            subwayAppbean = new SetSubwayDate().b();

            if (new EmergencyDeth(subwayAppbean).Emergency()) {
                System.out.println("发生紧急事件");
                break;
            } else {
                System.out.println( );
                System.out.println("第"+(a+1)+"位乘客");
                if (people.getSteal().equals("偷窃")) {
                    System.out.println("小偷");

                } else {
                    if (people.isHave_card()) {
                        if (new PeopleBaoDeth(people).jiancha_bao()) {
                            System.out.println("包有问题");
                        } else {
                            if (new PeopleBaoDeth(people).jiancha_water()) {
                                System.out.println("水有问题");
                            } else {
                                if (people.getYu_e() > 2) {
                                    System.out.println("进站");
                                    new TimeDeth(people).run();
                                } else {
                                    System.out.println("您的余额已不足");
                                    new SubwayCardDeth().congzhi(10, people);
                                    System.out.println("您余额充值后为" + people.getYu_e());
                                    System.out.println("进站");
                                    new TimeDeth(people).run();
                                }
                                if (people.getYu_e() >= new SubwayCardDeth().count_price(people.getStart(), people.getEnd())) {
                                    System.out.println("您的消费后的余额为" + (people.getYu_e() - new SubwayCardDeth().count_price(people.getStart(), people.getEnd())));

                                } else {
                                    new SubwayCardDeth().congzhi(10, people);
                                    System.out.println("您余额充值后为" + people.getYu_e());
                                    System.out.println("您的消费后的余额为" + (people.getYu_e() - new SubwayCardDeth().count_price(people.getStart(), people.getEnd())));
                                }
                            }
                        }
                    } else {
                        System.out.println("请您先购票");
                        new SubwayCardDeth().buycard();
                        if (new PeopleBaoDeth(people).jiancha_bao()) {
                            System.out.println("包有问题");
                        } else {
                            if (new PeopleBaoDeth(people).jiancha_water()) {
                                System.out.println("水有问题");
                            } else {
                                System.out.println("进站");
                                new TimeDeth(people).run();
                            }

                        }

                    }
                }
            }
        }

    }
}
